//
//  XIeYiViewController.m
//  ZhiBoYuan
//
//  Created by Coder_di on 2018/6/19.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "XIeYiViewController.h"

@interface XIeYiViewController ()<UIWebViewDelegate,UIScrollViewDelegate>

@end

@implementation XIeYiViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self setWebView];

}

-(void)setWebView{
    
    NSString *path;
    
    if (_isTeacher == YES) {
        self.title = @"用户协议";
        path = [[NSBundle mainBundle] pathForResource:@"教师用户协议" ofType:@"docx"];
    }else{
        self.title = @"用户协议";
        path = [[NSBundle mainBundle] pathForResource:@"学生注册协议" ofType:@"docx"];
    }
    
    NSURL *url = [NSURL fileURLWithPath:path];
    UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    [webView sizeToFit];
    webView.delegate = self;
    webView.scrollView.delegate = self;
    webView.scalesPageToFit = YES;
    if (_isComeFromLogin) {
        [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://h5.rrnjnx.com/#/tos"]]];
    }else{
       [webView loadRequest:[NSURLRequest requestWithURL:url]];
    }
    
    [self.view addSubview:webView];
    
    
}

-(void)webViewDidStartLoad:(UIWebView *)webView
{
    //开始加载网页调用此方法
    [MBProgressHUD showLoadingImageToView:self.view];
}

-(void)webViewDidFinishLoad:(UIWebView *)webView
{
    //网页加载完成调用此方法
    [MBProgressHUD hideHUDForView:self.view animated:YES];

    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
